package com.stone.mythread.juc;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

public class BlockingQueueDemo {
    public static void main(String[] args) {
        // 创建阻塞队列
        BlockingQueue<String> queue = new ArrayBlockingQueue<>(3);

        // put(e) - take() 会出现阻塞状态
        // add(e) - remove() 会出现异常
        // offer(e) - pool()
        // offer(e,time,unit) - poll(time,unit)

        System.err.println(queue.offer("a"));
        System.err.println(queue.offer("b"));
        System.err.println(queue.offer("c"));
        System.err.println(queue.offer("d"));

        System.err.println(queue.poll());
        System.err.println(queue.poll());
        System.err.println(queue.poll());
        System.err.println(queue.poll());
    }
}
